﻿using UnityEngine;
using UnityEngine.UI;
using System.Collections;

class GUIHandler : MonoBehaviour {

    private CharacterHandler p1;
    private CharacterHandler p2;
    private CharacterHandler p3;
    private CharacterHandler p4;
    private CharacterHandler p5;

    void Start () {
        p1 = GameObject.FindGameObjectWithTag("character1").GetComponent<CharacterHandler>();
        p2 = GameObject.FindGameObjectWithTag("character2").GetComponent<CharacterHandler>();
        p3 = GameObject.FindGameObjectWithTag("character3").GetComponent<CharacterHandler>();
        p4 = GameObject.FindGameObjectWithTag("character4").GetComponent<CharacterHandler>();
        p5 = GameObject.FindGameObjectWithTag("character5").GetComponent<CharacterHandler>();

        GameObject.Find("P1Text").GetComponent<Text>().text = "Player One: " + p1.getHealth();
        GameObject.Find("P2Text").GetComponent<Text>().text = "Player Two: " + p2.getHealth();
        GameObject.Find("P3Text").GetComponent<Text>().text = "Player Three: " + p3.getHealth();
        GameObject.Find("P4Text").GetComponent<Text>().text = "Player Four: " + p4.getHealth();
        GameObject.Find("P5Text").GetComponent<Text>().text = "Player Five: " + p5.getHealth();
    }

    void Update () {
        GameObject.Find("P1Text").GetComponent<Text>().text = "Player One: " + p1.getHealth();
        GameObject.Find("P2Text").GetComponent<Text>().text = "Player Two: " + p2.getHealth();
        GameObject.Find("P3Text").GetComponent<Text>().text = "Player Three: " + p3.getHealth();
        GameObject.Find("P4Text").GetComponent<Text>().text = "Player Four: " + p4.getHealth();
        GameObject.Find("P5Text").GetComponent<Text>().text = "Player Five: " + p5.getHealth();
    }

}

